home *** CD-ROM | disk | FTP | other *** search
- Path: news.infoserve.net!usenet
- From: yang@unix.infoserve.net (Sung Moo Yang)
- Newsgroups: comp.lang.c
- Subject: [Q] Does free() work?
- Date: 24 Feb 1996 04:23:55 GMT
- Organization: YANG Laboratories
- Message-ID: <4gm3ss$qfa@news.infoserve.net>
- NNTP-Posting-Host: d140.infoserve.net
- X-Newsreader: WinVN 0.92.5
-
- Question on the function free() in MSC 5.1 running on MS-DOS 6.0 on 486 DX2.
-
- The library function free() doesn't free memory allocated however _dos_freemem() does.
- Example TEST.C uses free() to release memory while TEST2.C uses _dos_freemem() to do so. Result screen was followed respectively.
-
- Why doesn't free() release the memory allocated?
- Thanks in advance.
-
- Sung Moo
-
-
-
-
-
-
-
-
- /* TEST.C
- Compiled by MSC 5.1
- */
- #include <stdlib.h>
- main()
- {
- char * p;
- p=(char*)malloc(3000);
- free(p);
- system("mem/mtest");
- }
-
- ------------------- RESULT SCREEN --------------
-
- C:\TEMP>test
-
- TEST is using the following memory:
-
- Segment Region Total Type
- ------- ------ ---------------- --------
- 01545 544 (1K) Environment
- 01567 70928 (69K) Program
- 026B8 3040 (3K) Data
- ----------------
- Total Size: 74512 (73K)
-
- ---------------------------------------------------
-
-
-
-
-
-
-
- /* TEST2.C
- Compiled by MSC 5.1
- */
- #include <dos.h>
- #include <stdlib.h>
- main()
- {
- char * p;
- p=(char*)malloc(3000);
- _dos_freemem(FP_SEG(p));
- system("mem/mtest2");
- }
-
-
- ------------------- RESULT SCREEN --------------
- C:\TEMP>test
-
- TEST2 is using the following memory:
-
- Segment Region Total Type
- ------- ------ ---------------- --------
- 01545 544 (1K) Environment
- 01567 70944 (69K) Program
- ----------------
- Total Size: 71488 (70K)
-
- -------------------------------------------------
-
-
-
-
-
-
-